#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using i128 = __int128;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

  int n;
  cin >> n;
  
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  ll ans = 0;
  vector<ll> ret(27);
  for (int i = 0; i <= 25; i++) {
    int N = 1 << i;
    vector<ll> c(N), s(N);
    for (int j = 0; j < n; j++) {
      int p = (-a[j] % N + N) % N;
      c[p]++; s[p] += a[j];
      int q = a[j] % N;
      ret[i] += (c[q] * a[j] + s[q]);
    }
  }

  for (int i = 0; i <= 25; i++) {
    ret[i] -= ret[i + 1];
    ans += ret[i] >> i;
  }
  cout << ans;
  return 0;
}